<template>
  <div class="container">
    <van-nav-bar title="底部文本随键盘输入评论框"
                 left-arrow
                 @click-left="()=>$router.go(-1)" />
    <div class="content">内容</div>
    <!-- 底部评论框 -->
    <GwTextAreaCommont class="commnent-bottom"
                       @pushState="pushState">
    </GwTextAreaCommont>
    <!-- 背景遮照 -->
    <van-overlay :show="keyBoardState"
                 duration="0.2"
                 @click="keyBoardState = false" />
  </div>
</template>
<script>
import { Overlay } from "vant";
import GwTextAreaCommont from "../components/gwTextAreaCommont.vue";
export default {
  name: "gwTextareaCommontView",
  components: {
    GwTextAreaCommont,
    [Overlay.name]: Overlay,
  },
  data() {
    return {
      // 从子控件传出来键盘的弹出状态
      keyBoardState: false,
    };
  },
  methods: {
    // 从子控件传出来键盘的弹出状态方法
    pushState(state) {
      console.log("state", state);
      this.keyBoardState = state;
    },
  },
};
</script>
<style lang="scss" scoped>
.container {
  height: 100%;
  width: 100%;
  position: relative;
  // 父视图需要和overlay遮照等级平级 评论框才不会被遮照挡住
  z-index: 1;
  .content {
    display: flex;
    // height: 100%;
    background-color: green;
  }
  .commnent-bottom {
    position: fixed;
    height: auto;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #f5f5f5;
    // 等级需要大于overlay遮照的等级
    z-index: 2;
  }
}
</style>